import Vue from "vue";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./permission";
//引用富文本编辑器
import VueQuillEditor from "vue-quill-editor";
//引入富文本css
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";

//打印
import KrPrintDesigner from "zqh-print-designer";
import "zqh-print-designer/lib/kr-print-designer.css";
import power from "./untils/power";
// //xlxs
// import FileSaver from 'file-saver'
// import XLSX from 'xlsx'
2;
//引用公用样式
import "./untils/commonL2.css";

//获取guid
function getGuid() {
    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
        var r = (Math.random() * 16) | 0,
            v = c == "x" ? r : (r & 0x3) | 0x8;
        return v.toString(16);
    });
}
//获取字符串像素
function getStringWidth(text) {
    let span = document.createElement("span");
    span.innerHTML = text;
    span.style.visibility = "hidden";
    span.setAttribute("class", "fontSize");
    let width = span.offsetWidth;
    document.getElementsByTagName("body")[0].removeChild(span);
    return width;
}

var loading;
//遮罩层 开启
function openLoading() {
    loading = this.$loading({
        lock: true,
        text: "加载中",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
    });
}
//遮罩层 关闭
function closeLoading() {
    loading.close();
}
//下载文件,blobFile文件流，FileName文件名得带后缀
function DownLoad(blobFile, FileName) {
    const blob = new Blob([blobFile]);
    const _fileName = FileName;
    if ("download" in document.createElement("a")) {
        // 非IE下载
        const elink = document.createElement("a");
        elink.download = _fileName;
        elink.style.display = "none";
        elink.href = URL.createObjectURL(blob);
        document.body.appendChild(elink);
        elink.click();
        URL.revokeObjectURL(elink.href); // 释放URL 对象
        document.body.removeChild(elink);
    } else {
        // IE10+下载
        navigator.msSaveBlob(blob, _fileName);
    }
}
Vue.prototype.$GetGuid = getGuid;
Vue.prototype.$GetStringWidth = getStringWidth;
Vue.prototype.$Power = power;
Vue.prototype.$DownLoad = DownLoad;
Vue.prototype.openLoading = openLoading;
Vue.prototype.closeLoading = closeLoading;

Vue.use(ElementUI, { size: "small" });
//富文本编辑器添加实例
Vue.use(VueQuillEditor);

Vue.use(KrPrintDesigner);

Vue.config.productionTip = false;

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount("#app");
